Trimesh Class

Used to represent a single triangular mesh in a 3D space. Used within an Rb3DSpace.

Events

None

Properties

HasVertexColors

VertexColors

HasVertexNormals

VertexCount

HasVertexUVs

VertexNormals

Material

VertexPositions

TriangleCount

VertexUVs

Triangles

 

Methods

None

More information available in parent classes: Element3D:Object


Notes

A Trimesh represents a triangular mesh that contains information about its vertices and faces. For each vertex, it contains information about its normals and colors. The Trimesh class lets you create or modify triangle meshes on-the-fly. With the Material class, you can modify textures and/or colors on-the-fly as well.

Trimesh uses four "helper" classes, TriangleList, UVList, VectorList, and ColorList, to set or get Trimesh data.


Example

This example creates one triangle with different vertex colors and places it in the 3D space.

Dim tm as New Trimesh
  
  // define the vertices
tm.VertexCount = 3
tm.VertexPositions.SetXYZ(0, 5, 5, 0 )
tm.VertexPositions.SetXYZ(1, 5, 10, 0 )
tm.VertexPositions.SetXYZ(2, 10, 10, 0 )
tm.HasVertexColors= True
tm.VertexColors.Item(0) = &cFF0000
tm.VertexColors.Item(1) = &c00FF00
tm.VertexColors.Item(2) = &c0000FF
  
  // define the triangles
tm.TriangleCount = 1
tm.Triangles.SetABC(0, 0, 1, 2)
  
  // add it to our display!
Rb3DSpace1.objects.Append tm

In order to see the Trimesh, you need to move the camera back away from the origin. This code in the RB3DSpace's Open event moves the camera so that you can get a good look at the multicolored Trimesh.

If Me.Objects = Nil then
  MsgBox "You need to install QD3D or Quesa!"
  Return
End if

Dim v as Vector3D
v= New Vector3D
v.X=10
v.Y=10
v.Z=10

//shift the light source for a better look
Me.FloodDirection.Z = - Me.FloodDirection.Z
Me.Camera.Position=v

See Also

Bounds3D, ColorList, Element3D, Group3D, Light3D, Material, Object3D, Quaternion, TriangleList, UVList, Vector3D, VectorList classes; Rb3DSpace control.